package com.wanma.recuit.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanma.recuit.mapper.ApplyMapper;
import com.wanma.recuit.mapper.DictionaryMapper;
import com.wanma.recuit.mapper.JobMapper;
import com.wanma.recuit.mapper.ResumeMapper;
import com.wanma.recuit.pojo.*;
import com.wanma.recuit.service.ManageResumeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Service
public class ManageResumeServiceImpl implements ManageResumeService {
    @Resource
    private ApplyMapper applyMapper;
    @Resource
    private ResumeMapper resumeMapper;
    @Resource
    private DictionaryMapper dictionaryMapper;
    @Resource
    private JobMapper jobMapper;

    @Override
    public void insert(Apply object) {

    }

    @Override
    public void delete(Integer id) {

    }

    @Override
    public void delete(String ids) {

    }

    @Override
    public void update(Apply object) {

    }

    @Override
    public Apply findById(Integer id) {
        return null;
    }

    @Override
    public List<Apply> findAll() {
        return null;
    }

    @Override
    public PageInfo<Apply> findPage(int pageNum, int pageSize) {
        return null;
    }
    //查出待处理的简历 并且是有条件的 如页码，搜索条件等
    public PageInfo<Apply> findPendingResume(Integer jobId,Integer workId,Integer eduId,Integer pageNum,Integer num,CompanyUser companyUser){
        Integer pageSize = 1;
        PageHelper.startPage(pageNum,pageSize);
        List<Apply> applies = applyMapper.findPendingResume(jobId,workId,eduId,num,companyUser);
        PageInfo<Apply>  pageInfo =  new PageInfo<>(applies,5);

        return pageInfo;
    }
    //查出接受邀请的简历 并且按时间段来查询
    public PageInfo<Apply> findAcceptInterviewResume(Date startTime,Date endTime,Integer num,Integer pageNum,CompanyUser companyUser){
        Integer pageSize = 1;
        PageHelper.startPage(pageNum,pageSize);
        System.out.println(startTime);
        System.out.println(endTime);
        System.out.println(num);
        System.out.println(companyUser.getId());
        List<Apply> applies = applyMapper.findAcceptInterviewResume(startTime, endTime, num, companyUser);

        PageInfo<Apply> pageInfo = new PageInfo<>(applies,5);
        System.out.println(pageInfo.getSize()+"222222222");
        return pageInfo;
    }
    //查出待处理简历的个数
    public int findPendingResumeNumber(CompanyUser companyUser,Integer num){
            return applyMapper.findPendingResumeNumber(companyUser,num);
    }
    //发送面试邀请，并发送面试的所有信息
    public void sendInterview(Apply apply){
        //得到系统的时间并格式化时间
//        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
//        df.format(new Date());// new Date()为获取当前系统时间

        applyMapper.sendInterview(apply,new Date());
    }
    //发送不合适 ，修改不合适的状态
    public void sendImproper(Integer jobId,Integer userId){
        applyMapper.sendImproper(jobId,userId,new Date());
    }
    //查出已经发送邀请的面试的简历的个数
    public Integer findInterviewedResumeNumber(CompanyUser companyUser){
        return applyMapper.findInterviewedResumeNumber(companyUser);
    }


    //查出簡歷的信息
    public Resume findResume(Integer id){return resumeMapper.findResume(id);}
    //查出字典表的工作年限表
    public List<Dictionary> findWorkExperience1(){
        return dictionaryMapper.findWorkExperience1();
    }
    //查出字典表的学历表
    public  List<Dictionary> findEduExperience1(){
        return dictionaryMapper.findEduExperience1();
    }
    //查出发布的职位
    public List<Job> findJob1(CompanyUser companyUser){
            return jobMapper.findJob1(companyUser);
    }
}
